package com.cnhis.cloudhealth.clidoctorweb.clideladvice;

import java.util.Map;

import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;

import com.cnhis.cloudhealth.commons.utils.StaticKeys;
import org.jboss.resteasy.logging.Logger;
import org.springframework.stereotype.Component;

import com.alibaba.dubbo.config.annotation.Reference;
import com.cnhis.cloudhealth.clinical.clidoctor.clideladvice.service.ICliDelAdvice;
import com.cnhis.cloudhealth.clinical.clidoctor.removeAdvice.service.IRemoveAdviceService;
import com.cnhis.cloudhealth.commons.Mappers.ModelVo;
import java.util.HashMap;
@Path("clideladvice")
@Component
public class CliDelAdviceRest {
	Logger log = Logger.getLogger(CliDelAdviceRest.class); 
	@Reference
	private ICliDelAdvice iCliDelAdvice;
	@Reference
	private IRemoveAdviceService removeAdviceService;

	/**
	 * ClinicAdvice_Del
	 * 删除医嘱单
	 * @param lXml
	 * @param lacf01
	 * @param BCE03
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings({ "unchecked", "rawtypes" })
	@POST
	@Path("clinicadvicedel")
	@Produces({ MediaType.APPLICATION_JSON })
	public ModelVo clinicAdviceDel(
			@FormParam("lXml") String lXml,
			@FormParam("lacf01") Integer lacf01,
			@FormParam("BCE03") String BCE03) throws Exception{
		Map map = new HashMap();
		map.put("lXml", lXml);
		map.put("lacf01", lacf01);
		map.put("BCE03", BCE03);
		return iCliDelAdvice.clinicAdviceDel(map);
	}
	/* ScriptId(7343) */
	/* Description(删除新开医嘱) */
	/*删除医嘱单的选择列表*/
	/**
	 * 
	 * @param lVaf06 就诊id
	 * @param VAF59 组号
	 * @param lVAF04 门诊
	 * @param CBM01 医嘱单id
	 * @param BCE01 医师id或操作者id
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings({ "unchecked", "rawtypes" })
	@POST
	@Path("deleteadvicelist")
	@Produces({ MediaType.APPLICATION_JSON })
	public ModelVo deleteAdviceList(
			@FormParam("lVaf06") int lVaf06,
			@FormParam("VAF59") int VAF59,
			@FormParam("lVAF04") int lVAF04,
			@FormParam("CBM01") int CBM01,
			@FormParam("BCE01") int BCE01
			)throws Exception{
		Map map = new HashMap();
		map.put("lVaf06", lVaf06);
		map.put("VAF59", VAF59);
		map.put("lVAF04", lVAF04);
		map.put("CBM01", CBM01);
		map.put("BCE01", BCE01);
		return iCliDelAdvice.deleteAdviceList(map);
	}
	
	/* ScriptId(7373) */
	/* Description(删除医嘱前签名验证) */
	/**
	 * 
	 * @param acf01
	 * @param VAF01 医嘱id
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings({ "unchecked", "rawtypes" })
	@GET
	@Path("deleteadvicelist")
	@Produces({ MediaType.APPLICATION_JSON })
	public ModelVo valuationSignDeleteAdvice(@QueryParam("acf01") int acf01,@QueryParam("VAF01") int VAF01,@QueryParam("ltxt") String ltxt)throws Exception{
		Map map = new HashMap();
		map.put("acf01", acf01);
		map.put("VAF01", VAF01);
		map.put("ltxt", ltxt);
		return iCliDelAdvice.valuationSignDeleteAdvice(map);
	}
	
	    /* ScriptId(7343) */
	    /* Description(删除新开医嘱) */
	/**
	 * 
	 * @param lVaf06 就诊ID
	 * @param lVAF04 类型（1：门诊、2：住院）
	 * @param CBM01 医嘱单ID
	 * @param BCE01 人员ID
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings({ "unchecked", "rawtypes" })
	@GET
	@Path("deleteadvicelist")
	@Produces({ MediaType.APPLICATION_JSON })
	public ModelVo queryAdvicePreDeleteList(@QueryParam("lVaf06") long lVaf06,
	                                        @QueryParam("lVAF04") int lVAF04,
	                                        @QueryParam("CBM01") long CBM01,
	                                        @QueryParam("BCE01") long BCE01)throws Exception{
	    Map map = new HashMap();
	    map.put("lVaf06", lVaf06);
	    map.put("lVAF04", lVAF04);
	    map.put("CBM01", CBM01);
	    map.put("BCE01", BCE01);
	    return iCliDelAdvice.queryAdvicePreDeleteList(map);
	}
	
	/**
	 * wj 删除医嘱
	 * @param vaf01s 界面上选择的vaf01字符串--例如：（1,2...）
	 * @return
	 */
	@SuppressWarnings({"unchecked", "rawtypes"})
    @POST
	@Path("removeAdvice")
    @Produces({ MediaType.APPLICATION_JSON })
	public ModelVo removeAdvice(@FormParam("vaf01s") String vaf01s,@FormParam("bce03") String bce03)
	{
		ModelVo mo = new ModelVo(StaticKeys.OH_SUCCESS);
	    Map map = new HashMap();
	    map.put("vaf01s", vaf01s);
	    map.put("bce03", bce03);
	    return removeAdviceService.removeAdvice(map);
	}
	/**
	 * wj 删除医嘱
	 * @param vaf01s 界面上选择的vaf01字符串--例如：（1,2...）
	 * @return
	 */
	@SuppressWarnings({"unchecked", "rawtypes"})
	@POST
	@Path("removeAdvice1")
	@Produces({ MediaType.APPLICATION_JSON })
	public ModelVo removeAdvice1(@FormParam("vaf01s") String vaf01s,@FormParam("bce03") String bce03,@FormParam("cbm01") String cbm01,
								@FormParam("lbce01") String lbce01,
								@FormParam("lmember") String lmember,@FormParam("date1") String date1 , @FormParam("date2") String date2,@FormParam("vak01s") String vak01s)
	{
		ModelVo mo = new ModelVo(StaticKeys.OH_SUCCESS);
		Map map = new HashMap();
		map.put("vaf01s", vaf01s);
		map.put("bce03", bce03);
		Map map1 = new HashMap();
		map1.put("cbm01", cbm01);
		map1.put("bce03", bce03);
		map1.put("lbce01", lbce01);
		map1.put("lmember", lmember);
		map1.put("date1", date1);
		map1.put("date2", date2);
		map1.put("vak01s", vak01s);
		mo = removeAdviceService.backAdvice(map1);
		if(mo.getResult().equals("Failure")){
			return mo;
		}
		return removeAdviceService.removeAdvice(map);
	}
	/**
	 * wj 医嘱回退
	 * @param vaf01s 界面上选择的vaf01字符串--例如：（1,2...）
	 * @return
	 */
	@SuppressWarnings({"unchecked", "rawtypes"})
	@POST
	@Path("backAdvice")
	@Produces({ MediaType.APPLICATION_JSON })
	public ModelVo backAdvice(@FormParam("cbm01") String cbm01,
	                          @FormParam("bce03") String bce03,
	                          @FormParam("lbce01") String lbce01,
                              @FormParam("lmember") String lmember,@FormParam("date1") String date1 , @FormParam("date2") String date2,@FormParam("vak01s") String vak01s)
	{
	    Map map = new HashMap();
	    map.put("cbm01", cbm01);
	    map.put("bce03", bce03);
	    map.put("lbce01", lbce01);
	    map.put("lmember", lmember);
		map.put("date1", date1);
		map.put("date2", date2);
		map.put("vak01s", vak01s);
	    return removeAdviceService.backAdvice(map);
	}
	
	/**
	 * wj 医嘱退费
	 * @param vaf01s 界面上选择的vaf01字符串--例如：（1,2...）
	 * @return
	 */
	@SuppressWarnings({"unchecked", "rawtypes"})
	@POST
	@Path("vby1")
	@Produces({ MediaType.APPLICATION_JSON })
	public ModelVo vby1(@FormParam("vaf01s") String vaf01s,
	    @FormParam("xml") String xml,
	    @FormParam("bce03") String bce03,
	    @FormParam("lbce01") String lbce01,
	    @FormParam("lmember") String lmember)
	{
	    Map map = new HashMap();
	    map.put("vaf01s", vaf01s);
	    map.put("xml", xml);
	    map.put("bce03", bce03);
	    map.put("lbce01", lbce01);
	    map.put("lmember", lmember);
	    return removeAdviceService.vby1(map);
	}
	/**
	 * mp 历史表转当前表
	 * @param vaf01s 界面上选择的vaf01字符串--例如：（1,2...）
	 * @return
	 */
	@SuppressWarnings({"unchecked", "rawtypes"})
	@POST
	@Path("horate_transfer_data")
	@Produces({ MediaType.APPLICATION_JSON })
	public ModelVo horate_transfer_data(@FormParam("date1") String date1 , @FormParam("date2") String date2,@FormParam("vak01s") String vak01s)
	{
		Map map = new HashMap();
		map.put("date1", date1);
		map.put("date2", date2);
		map.put("vak01s", vak01s);
		return removeAdviceService.horateTransferData(map);
	}
}
